package com.Home
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	import com.UI.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.tree.AbstractLayoutCache;
	public class FrameHomeBuilding6Tech extends FrameHomeBuilding
	{
		private var btn_tech:JButton;
		public function FrameHomeBuilding6Tech()
		{
			btn_tech = new JButton();
			btn_tech.setSize(new IntDimension(72, 23));
			btn_tech.setPreferredSize(new IntDimension(72, 23));
			btn_tech.setText("技术研究");
			
			panelButtons.append(btn_tech);
			
			btn_tech.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 14, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 5);
			btn_tech.setFont(font);
			btn_tech.setForeground(ASColor.WHITE);
			btn_tech.setTextFilters(new Array(filter));
			
			btn_tech.addActionListener(function():void{FrameHomeTechTech.show();});
		}

		override public function setImages():void
		{
			super.setImages();
			var img_char_background:DisplayObject = Client.getUIElement("img_home_bg_6") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			setSize(new IntDimension(img_char_background.width, img_char_background.height));
			setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
			setSizeWH(img_char_background.width,img_char_background.height);
			setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
			btn_dispatch.addActionListener(function():void{FrameHomeDispatch.show(objDest,_frame);});
			btn_accelerate.addActionListener(function():void{FrameHomeAccelerate.show(_frame);});
			
		}
		public static var _frame:FrameHomeBuilding6Tech = null;
		public static function show(obj:ObjectHomeBuilding):void
		{
			if(_frame == null)
			{
				_frame = new FrameHomeBuilding6Tech();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			if(!isShowing())
			{
				_frame.show();
				_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
				PanelMainHelp.getInstance().bringToTop(_frame);
			}
			_frame.update(obj);
			
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
	}
}

import com.*;
import com.Home.*;
import com.Engine.*;
import com.Home.FrameHomeBuilding;
import com.Packet.*;
import com.UI.*;

import flash.display.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;

import gs.*;
import gs.easing.*;
import gs.events.TweenEvent;


import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;
import org.aswing.tree.AbstractLayoutCache;

class FrameHomeTechTech extends JFrame
{
	
	//members define
	private var panelItems:JPanel;
	private var panelBCenter:JPanel;
	private var btnPrev:JButton;
	private var labelPage:JLabel;
	private var btnNext:JButton;
	
	/**
	 * MyPaneHomeTechTech Constructor
	 */
	private var btn_close:JButton;
	public function FrameHomeTechTech()
	{
		setResizable(false);
		setBorder(new EmptyBorder());
		
		btn_close = new JButton();
		btn_close.setLocation(new IntPoint(198, 0));
		btn_close.setSize(new IntDimension(27, 27));
		btn_close.setPreferredSize(new IntDimension(27, 27));
		this.getTitleBar().setCloseButton(btn_close);
		this.setClipMasked(false);
		getContentPane().setClipMasked(false);
		getTitleBar().getFrame().setClipMasked(false);
		btn_close.setClipMasked(false);
		getTitleBar().setMinimizeHeight(32);
		
		//component creation
		setSize(new IntDimension(367, 282));
		setPreferredSize(new IntDimension(367, 282));
		var layout0:EmptyLayout = new EmptyLayout();
		getContentPane().setLayout(layout0);
		
		panelItems = new JPanel();
		panelItems.setLocation(new IntPoint(9, 6));
		panelItems.setSize(new IntDimension(349, 204));
		panelItems.setPreferredSize(new IntDimension(349, 204));
		var layout1:GridLayout = new GridLayout();
		layout1.setRows(4);
		layout1.setColumns(1);
		layout1.setHgap(0);
		layout1.setVgap(0);
		panelItems.setLayout(layout1);
		
		panelBCenter = new JPanel();
		panelBCenter.setLocation(new IntPoint(132, 215));
		panelBCenter.setSize(new IntDimension(104, 24));
		panelBCenter.setPreferredSize(new IntDimension(104, 24));
		var layout2:FlowWrapLayout = new FlowWrapLayout();
		layout2.setPreferWidth(200);
		layout2.setAlignment(AsWingConstants.CENTER);
		layout2.setHgap(5);
		layout2.setVgap(0);
		layout2.setMargin(false);
		panelBCenter.setLayout(layout2);
		
		btnPrev = new JButton();
		btnPrev.setLocation(new IntPoint(-1, 0));
		btnPrev.setSize(new IntDimension(29, 24));
		btnPrev.setPreferredSize(new IntDimension(29, 24));
		btnPrev.setText("label");
		
		labelPage = new JLabel();
		labelPage.setLocation(new IntPoint(34, 3));
		labelPage.setSize(new IntDimension(36, 16));
		labelPage.setPreferredSize(new IntDimension(36, 16));
		labelPage.setText("label");
		
		btnNext = new JButton();
		btnNext.setLocation(new IntPoint(75, 0));
		btnNext.setSize(new IntDimension(29, 24));
		btnNext.setPreferredSize(new IntDimension(29, 24));
		btnNext.setText("label");
		
		//component layoution
		getContentPane().append(panelItems);
		getContentPane().append(panelBCenter);
		
		panelBCenter.append(btnPrev);
		panelBCenter.append(labelPage);
		panelBCenter.append(btnNext);
		
		setImages();
	}
	private var _mallItems:Array = new Array();
	public function setImages():void
	{
		
		var img_char_background:DisplayObject = Client.getUIElement("img_home_tech_bg") as DisplayObject
		setBackgroundDecorator(new AssetBackground(img_char_background));
		setSize(new IntDimension(img_char_background.width, img_char_background.height));
		setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
		setSizeWH(img_char_background.width,img_char_background.height);
		setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
		
		
		btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
		
		
		
		getContentPane().setClipMasked(false);
		setClipMasked(false);
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 14, false, false, false, false);
		
		btnPrev.wrapSimpleButton(Client.getUIElement("btn_prev") as SimpleButton);
		btnNext.wrapSimpleButton(Client.getUIElement("btn_next") as SimpleButton);
		btnPrev.setText("");
		btnNext.setText("");
		btnPrev.addActionListener(onBtnPrev);
		btnNext.addActionListener(onBtnNext);
		font = new ASFont("宋体", 12, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		labelPage.setForeground(ASColor.WHITE);
		labelPage.setFont(font);
		labelPage.setTextFilters(new Array(filter));
		
		for(var i:int = 0; i < _itemsPerPage; i++)
		{
			var item:PaneHomeTechTechItem = new PaneHomeTechTechItem;
			panelItems.append(item);
			_mallItems.push(item);
		}
		panelItems.setClipMasked(false);
		addEventListener(AWEvent.SHOWN,FrameHomeBuilding.onSecondFrameShown);
		addEventListener(FrameEvent.FRAME_CLOSING,FrameHomeBuilding.onSecondFrameClosing);
		addEventListener(AWEvent.HIDDEN,FrameHomeBuilding.onSecondFrameClosing);
	}

	private var _currentPageIndex:int = 0;
	private var _currentPageIndexAll:int = 0;
	private var _itemsPerPage:int = 4;
	public function updatePage():void
	{
		for each(var obj:Object in _mallItems)
		{
			obj.item = null;
		}
		var nIndex:int = 0;
		var nCount:int = 0;
		var array:Array = [];
		for each(var item:Object in array)
		{
			nCount++;
			if(nCount <= _currentPageIndex*_itemsPerPage)
				continue;
			_mallItems[nIndex++].item = item;
			if(nIndex >= _itemsPerPage)
				break;
		}
		
		var nCount1:int = array.length;
		_currentPageIndexAll = Math.floor((nCount1+_itemsPerPage-1)/_itemsPerPage);
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
		btnPrev.setEnabled(_currentPageIndex > 0 &&  _currentPageIndexAll > 1);
		btnNext.setEnabled(_currentPageIndex < _currentPageIndexAll-1 &&  _currentPageIndexAll > 1);
	}
	
	private function onBtnPrev(event:Event):void
	{
		_currentPageIndex--;
		if(_currentPageIndex < 0)
			_currentPageIndex = 0;
		else
			updatePage();
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
	}
	private function onBtnNext(event:Event):void
	{
		_currentPageIndex++;
		if(_currentPageIndex > _currentPageIndexAll-1)
			_currentPageIndex = _currentPageIndexAll-1;
		else
			updatePage();
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
	}
	
	public static var _frame:FrameHomeTechTech = null;
	public static function show():void
	{
		if(_frame == null)
		{
			_frame = new FrameHomeTechTech();
			PanelMainHelp.getInstance().addChild(_frame);
		}
		if(!isShowing())
		{
			_frame.show();
			_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
			PanelMainHelp.getInstance().bringToTop(_frame);
		}
		
		var frameHomeBuilding:FrameHomeBuilding = FrameHomeBuilding6Tech._frame;
		var teamDestX:int = (Engine.W - (_frame.width+frameHomeBuilding.width))/2;
		var teamDestY:int = (Engine.H - frameHomeBuilding.height)/2;
		
		var listDestX:int = teamDestX + frameHomeBuilding.width;
		var listDestY:int = teamDestY + (frameHomeBuilding.height - _frame.height)/2;
		
		var tween:TweenLite = TweenLite.to(frameHomeBuilding, 0.3, {x:teamDestX, y:teamDestY});
		var list_tween:TweenLite = TweenLite.to(_frame, 0.3, {x:listDestX, y:listDestY});
		
	}
	public static function hide():void
	{
		if(isShowing())_frame.hide();
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
	
	
	
}

/**
 * MyPaneHomeTechTechItem
 */
class PaneHomeTechTechItem extends JPanel{
	
	//members define
	private var panelIcon:JPanel;
	private var btn_research:JButton;
	private var labelDesc:MultilineLabel;
	
	/**
	 * MyPaneHomeTechTechItem Constructor
	 */
	public function PaneHomeTechTechItem(){
		//component creation
		setSize(new IntDimension(349, 51));
		setPreferredSize(new IntDimension(349, 51));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelIcon = new JPanel();
		panelIcon.setLocation(new IntPoint(0, 0));
		panelIcon.setSize(new IntDimension(50, 50));
		panelIcon.setPreferredSize(new IntDimension(50, 50));
		
		btn_research = new JButton();
		btn_research.setLocation(new IntPoint(58, 13));
		btn_research.setSize(new IntDimension(49, 25));
		btn_research.setPreferredSize(new IntDimension(49, 25));
		btn_research.setText("label");
		
		labelDesc = new MultilineLabel();
		labelDesc.setLocation(new IntPoint(119, 0));
		labelDesc.setSize(new IntDimension(230, 50));
		labelDesc.setPreferredSize(new IntDimension(230, 50));
		
		//component layoution
		append(panelIcon);
		append(btn_research);
		append(labelDesc);
		
		//----------------------
		
		panelIcon.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_default_image") as DisplayObject));
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
		
		btn_research.wrapSimpleButton(Client.getUIElement("btn_home_research") as SimpleButton);
		btn_research.setText("");
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		labelDesc.setForeground(ASColor.WHITE);
		labelDesc.setFont(font);
		labelDesc.filters = (new Array(filter));
		labelDesc.setBackgroundDecorator(null);
		
	}
}